home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / enigma / earcd / emula / arosdv19.lha / AROS / dos / pathpart.c < prev    next >
C/C++ Source or Header  |  1996-10-24  |  2KB  |  110 lines

  1. /*
  2.     (C) 1995 AROS - The Amiga Replacement OS
  3.     $Id: pathpart.c,v 1.2 1996/10/24 15:50:34 aros Exp $
  4.     $Log: pathpart.c,v $
  5.     Revision 1.2  1996/10/24 15:50:34  aros
  6.     Use the official AROS macros over the __AROS versions.
  7.  
  8.     Revision 1.1  1996/10/21 17:43:11  aros
  9.     A new function
  10.  
  11.     Desc:
  12.     Lang: english
  13. */
  14. #ifndef TEST
  15. #include "dos_intern.h"
  16. #else
  17. #define AROS_LH1(t,fn,a1,bt,bn,o,lib)     t fn (a1)
  18. #define AROS_LHA(t,n,r)                   t n
  19. #define AROS_LIBFUNC_INIT
  20. #define AROS_LIBBASE_EXT_DECL(bt,bn)
  21. #define AROS_LIBFUNC_EXIT
  22. #define CLIB_DOS_PROTOS_H
  23. #include <exec/types.h>
  24. #endif
  25.  
  26. /*****************************************************************************
  27.  
  28.     NAME */
  29.     #include <clib/dos_protos.h>
  30.  
  31.     AROS_LH1(STRPTR, PathPart,
  32.  
  33. /*  SYNOPSIS */
  34.     AROS_LHA(STRPTR, path, D1),
  35.  
  36. /*  LOCATION */
  37.     struct DosLibrary *, DOSBase, 146, Dos)
  38.  
  39. /*  FUNCTION
  40.     Returns a pointer to the character after the last
  41.     directory in path (see examples).
  42.  
  43.     INPUTS
  44.     path - Search this path.
  45.  
  46.     RESULT
  47.     A pointer to a character in path.
  48.  
  49.     NOTES
  50.  
  51.     EXAMPLE
  52.     PathPart("xxx:yyy/zzz/qqq") would return a pointer to the last '/'.
  53.     PathPart("xxx:yyy") would return a pointer to the first 'y').
  54.  
  55.     BUGS
  56.  
  57.     SEE ALSO
  58.  
  59.     INTERNALS
  60.  
  61.     HISTORY
  62.     29-10-95    digulla automatically created from
  63.                 dos_lib.fd and clib/dos_protos.h
  64.  
  65. *****************************************************************************/
  66. {
  67.     AROS_LIBFUNC_INIT
  68.     AROS_LIBBASE_EXT_DECL(struct DosLibrary *,DOSBase)
  69.     char * ptr;
  70.  
  71.     ptr = path;
  72.  
  73.     if (*ptr)
  74.     {
  75.     while (*ptr)
  76.     {
  77.         if (*ptr == '/')
  78.         path=ptr;
  79.         else if (*ptr == ':')
  80.         path=ptr+1;
  81.  
  82.         ptr ++;
  83.     }
  84.     }
  85.  
  86.     return path;
  87.     AROS_LIBFUNC_EXIT
  88. } /* PathPart */
  89.  
  90. #ifdef TEST
  91.  
  92. #include <stdio.h>
  93.  
  94. int main (int argc, char ** argv)
  95. {
  96.     UWORD i;
  97.     STRPTR s,fileptr;
  98.  
  99.     while (--argc)
  100.     {
  101.     s = *++argv;
  102.     fileptr = PathPart(s);
  103.  
  104.     printf("Pfad:  %s\nErg.: %s\n", s, fileptr);
  105.     }
  106. }
  107.  
  108. #endif /* TEST */
  109.  
  110.